const $api = "http://192.168.16.104:8080/system/";
const $url = "http://localhost:63342/practice/template/layuimini/";


// 验证当前的浏览器中的token是否过期
function verifyToken() {
    console.log("进入了token统一认证方法内");

    // 1.判断是否浏览器是否存有token
    let token = layui.data('table')['Authorization'];
    if (typeof token == "undefined" || token == null || token === "") {
        window.location = $url + "page/login-3.html";
    }

    // 2.判断当前的token是否过期
    var $ = layui.jquery;

    $.ajax({
        type: 'GET',
        url: $api + 'user/check/token',
        contentType: "application/json;charset=utf-8",
        async: true,
        headers: {
            'Authorization': layui.data('table')['Authorization']
        },
        success: function (res) {
            identifyCode(res);
        }
    });


}

// 对状态码进行检验，如果满足以下条件，需要重新登陆
function identifyCode(res) {
    console.log("当前的请求结果是" + JSON.stringify(res).toString())

    if(res.code == 1005){
        layer.msg(res.message);
        return false

    }

    // 出现以下状态码，需要重新登陆
    if (res.code == 1000 || res.code == 1001 || res.code == 1003) {
        console.log("进入了状态码统一认证方法1内");

        if (confirm(res.message + "，请重新登陆")) {
            window.location = $url + "page/login-3.html";
        }
    }
    // 出现以下状态码，提示对应的错误信息
    if(res.code == 10001 || res.code ==10002 ||res.code == 10003){
        console.log("进入了状态码统一认证方法2内");

        layer.msg(res.message);
        return false
    }

}

// 获取页面传递的参数
function getQueryString(parm) {
    var reg = new RegExp("(^|&)" + parm + "=([^&]*)(&|$)", "i");
    var r = window.location.search.substr(1).match(reg);
    if (r !== null)
        return unescape(r[2]);
    return null;
}


// 通过role获取具体的类型
function getRole(role){
    switch (role) {
        case 1:
            return "系统管理员";
            break;
        case 2:
            return '企业管理员';
            break;
        case 3:
            return '项目负责人';
            break;
        case 4:
            return '专家';
            break;
        case 5:
            return '商务管理员';
            break;
        default:
            return "无此对象"
    }
}

// 通过status获取具体的状态
function getStatus(status){
    switch (status) {
        case 0:
            return "正常";
            break;
        case 1:
            return '注销';
            break;
        case 3:
            return '黑名单';
            break;
        default:
            return "无"
    }
}
function getStation(typeId){
    switch (typeId) {
        case 1:
            return "精英部门";
            break;
        case 1:
            return '教育部门';
            break;
        case 3:
            return '风险部门';
            break;
        default:
            return "无"
    }
}
function getRiskType(rkey){
    switch (rkey) {
        case 1:
            return "待办工作";
            break;
        case 2:
            return '意见建议';
            break;
        case 3:
            return "业务超时";
            break;
        case 4:
            return '业务过短';
            break;
        case 5:
            return "投诉举报";
            break;
        case 6:
            return '业务卡顿';
            break;
        default:
            return "其他"
    }
}
function getFlow(fid){
    switch (fid) {
        case 1:
            return "资金综合管理业务";
            break;
        case 2:
            return '干部选拔运行流程';
            break;
        default:
            return "其他"
    }
}

function getVerify(verify){
    switch (verify){
        case 0:
            return "已申请";
            break;
        case 1:
            return "已验证";
            break;
        case -1:
            return "已拒绝";
            break;
        default:
            return "未申请"
    }
}

function getVerifyVo(verify){
    switch (verify){
        case "已申请":
            return 0;
            break;
        case "已验证":
            return 1;
            break;
        case "已拒绝":
            return -1;
            break;
        default:
            return null
    }
}

function getPutOnRecords(putOnRecords){
    switch (putOnRecords){
        case 0:
            return "未备案";
            break;
        case 1:
            return "已备案";
            break;
        case -1:
            return "未通过";
            break;
        default:
            return "未申请"
    }
}

function getPutOnRecordsVo(putOnRecords){
    switch (putOnRecords){
        case "未备案":
            return 0;
            break;
        case "已备案":
            return 1;
            break;
        case "未通过":
            return -1;
            break;
        default:
            return null
    }
}

function getCheckAccept(checkAccept){
    switch (checkAccept){
        case 0:
            return "未验收";
            break;
        case 1:
            return "已验收";
            break;
        case 2:
            return "正在验收";
            break;
        case 3:
            return "完成验收";
            break;
        default:
            return "未验收"
    }
}

function getCheckAcceptVo(checkAccept){
    switch (checkAccept){
        case "未验收":
            return 0;
            break;
        case "已验收":
            return 1;
            break;
        default:
            return null
    }
}

function getProjectType(projectType){
    switch (projectType){
        case 1:
            return "内贸流通发展专项资金项目";
            break;
        case 2:
            return "外经贸发展专项资金项目";
            break;
        case 3:
            return "服务外包业产业发展专项资金项目";
            break;
        case 4:
            return "区域服务业发展专项资金项目";
            break;
        case 5:
            return "市商务委部门专项资金项目";
            break;
        case 6:
            return "规划分配专项资金项目";
            break;
    }
}
function getProjectTypeVo(projectType){
    switch (projectType){
        case "内贸流通发展专项资金项目":
            return 1;
            break;
        case "外经贸发展专项资金项目":
            return 2;
            break;
        case "服务外包业产业发展专项资金项目":
            return 3;
            break;
        case "区域服务业发展专项资金项目":
            return 4;
            break;
        case "市商务委部门专项资金项目":
            return 5;
            break;
        case "规划分配专项资金项目":
            return 6;
            break;
    }
}
function getFileState(fileState){
    switch (fileState){
        case 0:
            return "未授权";
            break;
        case 1:
            return "已授权";
            break;
    }

}

function getRiskFileStaffStation(state){
    switch (state){
        case 0:
            return "未完成";
            break;
        case 1:
            return "已完成";
            break;
    }

}

function getActivate(activate){
    switch (activate){
        case 0:
            return "未激活";
            break;
        case 1:
            return "已激活";
            break;
    }
}

function getRoleType(role){
    switch (role){
        case 0:
            return "普通员工";
            break;
        case 1:
            return "项目负责人";
            break;
    }
}

function getExpertType(type){
    switch (type) {
        case 1:
            return "普通专家";
        case 2:
            return "特级专家";
        default:
            return "无";
    }
}

let count = 0;
let html = "";
let syshtml = " ";
let norhtml = " ";
let page = 1;

let list = [];